package com.webchat.client.mall.service.im;


import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.exception.BusinessException;
import com.webchat.domain.vo.dto.mall.im.UgcServerMessageDTO;
import com.webchat.rmi.ugc.mall.im.MallChatMessageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MallChatMessageService {

    @Autowired
    private MallChatMessageClient mallChatMessageClient;

    /**
     * 商家智能客服对话消息列表查询
     *
     * @param account
     * @param chatAccount
     * @param lastTime
     * @param size
     * @param loadScreenNo
     * @return
     */
    public List<UgcServerMessageDTO> list(String account, String chatAccount,
                                          Long lastTime, int size, int loadScreenNo) {

        APIResponseBean<List<UgcServerMessageDTO>> response =
                mallChatMessageClient.list(account, chatAccount, lastTime, size, loadScreenNo);
        if (APIResponseBeanUtil.isOk(response)) {
            return response.getData();
        }
        throw new BusinessException("聊天消息列表加载失败～");
    }


}
